package com.fmatos.amazingwallpapers.dagger;

import javax.inject.Singleton;

import android.app.Activity;
import android.content.Context;

import com.fmatos.amazingwallpapers.image.AsyncCloudManager;
import com.fmatos.amazingwallpapers.view.albums.AlbumsActivity;
import com.fmatos.amazingwallpapers.view.albums.AlbumsViewSource;

import dagger.Module;
import dagger.Provides;

// TODO start using component
@Module (
		injects=  { 
				AlbumsViewSource.class,
				AlbumsActivity.PlaceholderFragment.class, // class that is allowed to call getApplication()).inject(this)
				AsyncCloudManager.class
		}
		//		includes=FileManager.class,
		//library=true // this won't make checks for unused providers
		)
public class DaggerMasterModule { 

	private final AmazingApplication application;

	public DaggerMasterModule(AmazingApplication application) {
		this.application = application;
	}

	/**
	 * Allow the application context to be injected but require that it be annotated with
	 * {@link ForApplication @Annotation} to explicitly differentiate it from an activity context.
	 */
	@Provides @Singleton 
	//	  @ForApplication 
	Context provideApplicationContext() {
		return application;
	}

	@Provides @Singleton
	Activity provideActivity() {
		return application.getCurrentActivity();
	}
}


/*
 * Creates a CoffeeApp inside another class
 * Makes sure the CoffeApp gets the @Inject CoffeeMaker coffeeMaker right
 * CoffeMaker has a @Inject Lazy<Heater> heater; 
 * CoffeMaker has a @Inject Pump pump
 * 
@Module(
	    injects = CoffeeApp.class,
	    includes = PumpModule.class
	)
	class DripCoffeeModule {
	  @Provides @Singleton Heater provideHeater() {
	    return new ElectricHeater();
	  }
	}
 */
